package com.example.service.impl;

import com.example.dao.VolunteerDao;
import com.example.entity.Users;
import com.example.entity.Volunteer;
import com.example.service.VolunteerService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class VolunteerServiceImpl implements VolunteerService {
    @Autowired
    private VolunteerDao volunteerDao;

    @Override
    public List<Volunteer> getAllVolunteer() {
        return volunteerDao.findAllVolunteer();
    }
    @Override
    public Volunteer getVolunteerByVolunteer_Id(Integer volunteer_id) {
        return volunteerDao.findVolunteerByVolunteer_Id(volunteer_id);
    }
    @Override
    public boolean addVolunteer(Volunteer volunteer) {return volunteerDao.insertVolunteer(volunteer) > 0;}

    @Override
    public boolean updateVolunteer(Volunteer volunteer) {
        return volunteerDao.updateVolunteer(volunteer) > 0;
    }

    @Override
    public boolean deleteVolunteer(Integer volunteer_id) {
        return volunteerDao.deleteVolunteer(volunteer_id) > 0;
    }

    @Override
    public List<Volunteer> searchVolunteer(@Param("name") String name, @Param("sex") String sex) {return volunteerDao.searchVolunteer(name,sex);}
}
